﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class tset1 : System.Web.UI.Page
{
    public static int f;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            binddata();
        }
    }
    protected void btclick_Click(object sender, EventArgs e)
    {
        P2.Visible = true;
        f = 0;
    }
    protected void btclick1_Click(object sender, EventArgs e)
    {
        P2.Visible = true;
        f = 1;
    }
    protected void Drop_yuar_SelectedIndexChanged(object sender, EventArgs e)
    {
        Calendar1.VisibleDate = Convert.ToDateTime(this.Drop_yuar.SelectedValue + "-" +
            DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString());
    }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        if (f == 0)
        {
            this.Tdata.Text = Calendar1.SelectedDate.ToShortDateString();
            P2.Visible = false;
            f = 1;
        }
        else
        {
            this.Tdata1.Text = Calendar1.SelectedDate.ToShortDateString();
            P2.Visible = false;
            f = 0;
        }
    }
    protected void bton_Click(object sender, EventArgs e)
    {
        if (ddl.Text == "" && Tdata.Text == "" && Tdata1.Text == "")
        {
            Response.Write("<script>alert('请输入查询条件')</script>");
        }
        else
            if (Tdata.Text != "" && Tdata1.Text == "")
            {
                Response.Write("<script>alert('请输入截止日期')</script>");
            }
            else
                if (Tdata.Text == "" && Tdata1.Text != "")
                {
                    Response.Write("<script>alert('请输入开始日期')</script>");
                }
                else
                {
                    Session["id"] = ddl.Text;
                    Session["bdata"] = Tdata.Text.Trim();
                    Session["ldata"] = Tdata1.Text.Trim();
                    Response.Write("<script type=\"text/javascript\">window.open('findappllylistshow.aspx','_blank');</script>");   
                }
    }
    protected void btoff_Click(object sender, EventArgs e)
    {
        ddl.SelectedIndex = 0;
        Tdata1.Text = null;
        Tdata.Text = null;
    }
    protected void binddata()
    {
        string str = "SELECT id FROM applylist;";
        sqldata sd = new sqldata();
        sd.dropdownlistdatabind(str, ddl);
        ListItem nulllist = new ListItem();
        ddl.Items.Insert(0, nulllist);
    }
}
